<?php
/* Smarty version 3.1.34-dev-7, created on 2020-07-09 16:22:06
  from 'D:\php_demo\kindergarten\application\views\templates\admin\teacher_operating.html' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '3.1.34-dev-7',
  'unifunc' => 'content_5f06d3ae04f691_57426710',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '52e8182fd1228f24b5e0448701dfc30663341506' => 
    array (
      0 => 'D:\\php_demo\\kindergarten\\application\\views\\templates\\admin\\teacher_operating.html',
      1 => 1594282018,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_5f06d3ae04f691_57426710 (Smarty_Internal_Template $_smarty_tpl) {
?><!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>首页</title>
		<link href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.2/theme-chalk/index.css" rel="stylesheet">
		<?php echo '<script'; ?>
 src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"><?php echo '</script'; ?>
>
		<!-- import Vue before Element -->
		<?php echo '<script'; ?>
 src="/html/vue.js"><?php echo '</script'; ?>
>
		<!-- import JavaScript -->
		<?php echo '<script'; ?>
 src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.2/index.js"><?php echo '</script'; ?>
>
		<?php echo '<script'; ?>
 src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"><?php echo '</script'; ?>
>
		<?php echo '<script'; ?>
 type="text/javascript" src="/html/wangEditor.min.js"><?php echo '</script'; ?>
>
	</head>
	<body>
		<div id="app" style='width: 100%; height: 100%;'>
			<el-container style="height: 100%; border: 1px solid #eee">
				<el-aside width="200px">
					<el-menu :default-openeds="['1', '3']">
						<el-submenu index="1">
							<template slot="title"><i class="el-icon-message"></i>文章</template>
							<el-menu-item-group>
								<template slot="title">分组一</template>
								<!-- <el-menu-item index="1-1" class="el-menu-item is-active"><el-link href="#">文章管理</el-link></el-menu-item> -->
								<el-link href="/index.php/admin_to/admin">
									<el-menu-item index="1-1">文章管理</el-menu-item>
								</el-link>
								<el-link href="/index.php/admin_to/write_news" target="_blank" :underline="false">
									<el-menu-item index="1-2">文章编写</el-menu-item>
								</el-link>
							</el-menu-item-group>
							<el-menu-item-group title="分组2">
								<el-link href="/index.php/admin_to/modify">
									<el-menu-item index="1-3">文章修改</el-menu-item>
								</el-link>
								<el-link href="/index.php/admin_to/view">
									<el-menu-item index="1-4">文章查看</el-menu-item>
								</el-link>
							</el-menu-item-group>
							<el-submenu index="1-4">
								<template slot="title">分类</template>
								<el-link href="/index.php/admin_to/classification">
									<el-menu-item index="1-4-1">文章分类</el-menu-item>
								</el-link>
							</el-submenu>
						</el-submenu>
						<el-submenu index="2">
							<template slot="title"><i class="el-icon-menu"></i>资源</template>
							<el-menu-item-group>
								<template slot="title">分组一</template>

								<el-link href="/index.php/admin_to/video_material">
									<el-menu-item index="2-1">视频管理</el-menu-item>
								</el-link>

								<el-menu-item index="2-2">选项2</el-menu-item>
							</el-menu-item-group>
							<el-menu-item-group title="分组2">
								<el-menu-item index="2-3">选项3</el-menu-item>
							</el-menu-item-group>
							<el-submenu index="2-4">
								<template slot="title">选项4</template>
								<el-menu-item index="2-4-1">选项4-1</el-menu-item>
							</el-submenu>
						</el-submenu>
						<el-submenu index="3">
							<template slot="title"><i class="el-icon-setting"></i>导航三</template>
							<el-menu-item-group>
								<template slot="title">分组一</template>

								<el-link href="/index.php/admin_to/teacher_list">
									<el-menu-item index="3-1">老师信息列表</el-menu-item>
								</el-link>

								<el-link href="#">
									<el-menu-item index="3-2" class="el-menu-item is-active">信息操作层</el-menu-item>
								</el-link>

							</el-menu-item-group>
							<el-menu-item-group title="分组2">
								<el-link href="/index.php/admin_to/course_list">
									<el-menu-item index="3-3">课程信息列表</el-menu-item>
								</el-link>
								<el-menu-item index="3-4">信息操作层</el-menu-item>
							</el-menu-item-group>
							<el-menu-item-group title="分组3">
								<el-link href="/index.php/admin_to/equipment_list">
									<el-menu-item index="3-5">设备信息列表</el-menu-item>
								</el-link>
								<el-menu-item index="3-6">信息操作层</el-menu-item>
							</el-menu-item-group>
							<el-submenu index="3-7">
								<template slot="title">选项4</template>
								<el-menu-item index="3-7-1">选项4-1</el-menu-item>
							</el-submenu>
						</el-submenu>
					</el-menu>
				</el-aside>

				<el-container>
					<el-header style="text-align: right; font-size: 12px">
						<el-dropdown @command="user_list">
							<i class="el-icon-setting" style="margin-right: 15px"></i>
							<el-dropdown-menu slot="dropdown">
								<el-dropdown-item command="a">查看</el-dropdown-item>
								<el-dropdown-item command="b">新增</el-dropdown-item>
								<el-dropdown-item command="c">退出登录</el-dropdown-item>
							</el-dropdown-menu>
						</el-dropdown>
						<span>{{ name }}</span>
					</el-header>

					<el-main>
						<el-row style='margin-top: 10px;'>
							<el-col :span="6">
								姓名：
							</el-col>
							<el-col :span="6">
								<el-input v-model="username" placeholder="请输入姓名"></el-input>
							</el-col>
							<el-col :span="6"></el-col>
							<el-col :span="6"></el-col>
						</el-row>

						<el-row style='margin-top: 10px;'>
							<el-col :span="6">
								职位名称：
							</el-col>
							<el-col :span="6">
								<el-input v-model="position" placeholder="请输入职位名称"></el-input>
							</el-col>
							<el-col :span="6"></el-col>
							<el-col :span="6"></el-col>
						</el-row>

						<el-row style='margin-top: 10px;'>
							<el-col :span="6">
								性别：
							</el-col>
							<el-col :span="6">
								<el-radio v-model="sex" label="男">男</el-radio>
								<el-radio v-model="sex" label="女">女</el-radio>
							</el-col>
							<el-col :span="6"></el-col>
							<el-col :span="6"></el-col>
						</el-row>

						<el-row style='margin-top: 10px;'>
							<el-col :span="6">
								权力值：
							</el-col>
							<el-col :span="6">
								<el-input v-model="power" placeholder="请输入数字"></el-input>
							</el-col>
							<el-col :span="6"></el-col>
							<el-col :span="6"></el-col>
						</el-row>

						<el-row style='margin-top: 30px;'>
							<el-col :span="6">标题图片：</el-col>
							<el-col :span="6">
								<el-upload class="avatar-uploader" action="/index.php/news/do_upload_image" :show-file-list="false" :on-success="handleAvatarSuccess"
								 :before-upload="beforeAvatarUpload">
									<img v-if="title_url" :src="title_url" class="avatar">
									<i v-else class="el-icon-plus avatar-uploader-icon"></i>
								</el-upload>
							</el-col>
							<el-col :span="6">
							</el-col>
							<el-col :span="6"></el-col>
						</el-row>

						<el-row style='margin-top: 30px;'>
							<el-col :span="24">
								<div id="editor">
									<p>欢迎使用 <b>Editor</b> 富文本编辑器</p>
								</div>
							</el-col>
						</el-row>
						<el-row style='margin-top: 30px;'>
							<el-button type="primary" v-on:click="go_tijiao()">提交</el-button>
						</el-row>
					</el-main>

				</el-container>
			</el-container>
		</div>


		<?php echo '<script'; ?>
>
			new Vue({
				el: '#app',
				data: function() {
					return {
						name: "admin",
						username: "",
						position: "",
						sex: "",
						power: "",
						content: "",
						title_url: "",
						teacher_id: -10
					}
				},
				methods: {
					go_tijiao() {
						var me = this;
						me.content = editor.txt.html();
						if (me.username == "" || me.position == "" || me.sex == "" || me.power == "" || me.content == "") {
							this.$message({
								message: '警告,填写所有内容不能为空!',
								type: 'warning'
							});
							return;
						}
						const params = new URLSearchParams();
						params.append("id", me.teacher_id);
						params.append("name", me.username);
						params.append("position", me.position);
						params.append("content", me.content);
						params.append("sex", me.sex);
						params.append("power", me.power);
						params.append("title_url", me.title_url);
						//提交文章
						axios({
							method: 'post',
							url: '/index.php/server/teacher/write',
							hheaders: {
								'content-type': 'application/x-www-form-urlencoded'
							},
							data: params
						}).then(function(response) {
							//console.log(response);

							sessionStorage.setItem("teacher_id", "");
							sessionStorage.setItem("username", "");
							sessionStorage.setItem("position", "");
							sessionStorage.setItem("sex", "");
							sessionStorage.setItem("content", "");
							sessionStorage.setItem("power", "");
							sessionStorage.setItem("title_url", "");

							window.location.href = "/index.php/admin_to/teacher_list";
						});
					},
					user_list(command) {
						if (command == "c") {
							axios.get('/index.php/server/login/ex_login', {
									params: {}
								})
								.then(function(response) {
									//console.log(response);							
									window.location.href = "/index.php/server/login/go";
									return
								})
								.catch(function(error) { // 请求失败处理
									//console.log(error);
								});

						}
						//console.log(command);
						var username = sessionStorage.getItem("name");
						if (username != 'admin') {
							this.$message({
								message: '只有admin账户拥有此权限！',
								type: 'warning'
							});
							return;
						}
						window.location.href = "/index.php/admin_to/user_list";
					},
					handleAvatarSuccess(res, file) {
						//console.log(res);
						//console.log(file);
						this.title_url = res.data.src;
					},
					beforeAvatarUpload(file) {
						//console.log(file);
						const isJPG = file.type === 'image/jpeg' || 'image/png' || 'image/gif';
						const isLt2M = file.size / 1024 / 1024 < 5;
						if (!isJPG) {
							this.$message.error('上传头像图片只能是 JPG/png/gif 格式!');
						}
						if (!isLt2M) {
							this.$message.error('上传头像图片大小不能超过 2MB!');
						}
						return isJPG && isLt2M;
					}
				},
				created: function() {

					var me = this;
					//console.log('created');
					me.teacher_id = sessionStorage.getItem("teacher_id");
					me.name = sessionStorage.getItem("name");
					me.username = sessionStorage.getItem("username");
					me.position = sessionStorage.getItem("position");
					me.sex = sessionStorage.getItem("sex");
					me.power = sessionStorage.getItem("power");
					me.title_url = sessionStorage.getItem("title_url");
					//editor.txt.html(sessionStorage.getItem("content"));
				}
			})
		<?php echo '</script'; ?>
>
		<?php echo '<script'; ?>
 type="text/javascript">
			var E = window.wangEditor
			var editor = new E('#editor')
			// 或者 var editor = new E( document.getElementById('editor') )
			editor.customConfig.uploadImgServer = '/index.php/news/do_upload_image2' // 上传图片到服务器
			editor.customConfig.withCredentials = true
			editor.customConfig.uploadFileName = 'file'
			editor.create()
			editor.txt.html(sessionStorage.getItem("content"));
		<?php echo '</script'; ?>
>

		<style>
			.el-header {
				background-color: #D9ECFF;
				color: #303133;
				line-height: 60px;
			}

			.avatar-uploader .el-upload {
				border: 1px dashed #d9d9d9;
				border-radius: 6px;
				cursor: pointer;
				position: relative;
				overflow: hidden;
			}

			.avatar-uploader .el-upload:hover {
				border-color: #409EFF;
			}

			.avatar-uploader-icon {
				font-size: 28px;
				color: #8c939d;
				width: 178px;
				height: 178px;
				line-height: 178px;
				text-align: center;
			}

			.avatar {
				width: 178px;
				height: 178px;
				display: block;
			}
		</style>
	</body>
</html>
<?php }
}
